<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>输入数字打印形状</title>
</head>
<body>
    <script>
        var i = prompt("请输入行数：", "");
        
        document.write("<h3>三角形:</h3>");
        for (var a = 1; a <= i; a++) {       // 行数
            for (var b = 1; b <= a; b++) {   // 列数
                document.write("※");
            }
            document.write("<br>");          // 每行输出后换行；
        }
        
        document.write("<h3>平行四边形:</h3>");
        for (var a = 1; a <= i; a++) {
            for (var b = 1; b <= i - a; b++) {
                document.write("&nbsp;&nbsp;");  // 用于形成空格间距
            }
            for (var c = 1; c <= i; c++) {
                document.write("※");
            }
            document.write("<br>");
        }
    </script>
</body>
</html>

